package com.cy.pj.notice.dao.impl;

import com.cy.pj.notice.dao.SysNoticeDao;
import com.cy.pj.notice.pojo.SysNotice;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

//@Component
//@Repository
public class SysNoticeDaoImpl implements SysNoticeDao {

    @Autowired
    private SqlSession sqlSession;

    @Override
    public List<SysNotice> selectNotice(SysNotice notice) {
        //反射获取接口的类全名
        //this:当前对象SysNoticeDaoImpl
        //this.getClass()反射的字节码对象,
       //this.getClass().getInterfaces()[0]获取实现类当前接口

        String interfaceName =this.getClass().getInterfaces()[0].getName();

       // String methodName = this.getClass().getMethods()[0].getName();
        //getStackTrace()获取当前线程的方法栈,
        // 并获取当前方法的名字.当前方法一般为数组1

        String elementId = Thread.currentThread().getStackTrace()[1].getMethodName();

        //String statement = "com.cy.pj.notice.dao.SysNoticeDao.selectNotice";

        String statement = interfaceName+"."+elementId;
        //通过selectList查询出list数组,参数为
        List<SysNotice> list = sqlSession.selectList(statement, notice);
        return list;
    }

    @Override
    public int deleteById(Long... id) {
        return 0;
    }

    @Override
    public int insertNotice(SysNotice notice) {
        return 0;
    }

    @Override
    public SysNotice findById(Long id) {
        return null;
    }

    @Override
    public int updateNotice(SysNotice notice) {
        return 0;
    }
}
